<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Web Solutions
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2005/06/21 03:25:41 $)
// $RCSfile: staff_ajax.php,v $ : $Revision: 1.1 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================


if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

require_once ("./modules/livesupport/functions_livesupport.php");
require_once ("./modules/livesupport/functions_chathistory.php");
require_once ("./includes/functions_html.php");
$template->loadLanguageSection("chathistory");


/**
* ###############################################
* HISTORY
* ###############################################
*/
if ($_GET["action"] == "history")
{
	$_emaillist = $_history = array();
	if (!empty($_GET["email"]))
	{
		if (!is_array($_GET["email"]))
		{
			$_emaillist = array($_GET["email"]);
		} else {
			foreach ($_GET["email"] as $key=>$val)
			{
				if (!empty($val))
				{
					$_emaillist[] = $val;
				}
			}
		}
	}

	if (count($_emaillist))
	{
		$dbCore->query("SELECT * FROM `". TABLE_PREFIX ."chatobjects` WHERE `useremail` IN (". buildIN($_emaillist) .");");
		while ($dbCore->nextRecord())
		{
			$_history[$dbCore->Record["chatobjectid"]] = $dbCore->Record;
		}
	}

	echo '<table border="0" cellpadding="3" cellspacing="1" width="100%" class="tborder"><tr class="tabletitlerow"><td align="left" width="80">'. $_SWIFT["language"]["chatid"] .'</td><td align="left" width="">'. $_SWIFT["language"]["fullname"] .'</td><td align="center" width="180">'. $_SWIFT["language"]["staffname"] .'</td><td align="center" width="150">'. $_SWIFT["language"]["chatdepartment"] .'</td><td align="center" width="180">'. $_SWIFT["language"]["date"] .'</td></tr>';
	foreach ($_history as $key=>$val)
	{
		echo '<tr class="'. getRowBG() .'"><td align="left" width="120"><a href="index.php?_m=livesupport&_a=viewchat&chatobjectid='. $val["chatobjectid"] .'" target="_blank">'. htmlspecialchars($val["chatobjectid"]) .'</a></td><td align="left" width=""><a href="index.php?_m=livesupport&_a=viewchat&chatobjectid='. $val["chatobjectid"] .'" target="_blank">'. htmlspecialchars($val["userfullname"]) .'</a></td><td align="center" width="150">'. $_SWIFT["staffcache"][$val["staffid"]]["fullname"] .'</td><td align="center" width="150">'. htmlspecialchars($_SWIFT["departmentcache"][$val["departmentid"]]["title"]) .'</td><td align="center" width="120">'. edate($_SWIFT["settings"]["dt_datetimeformat"], $val["dateline"]) .'</td></tr>';
	}
	echo '</table><BR />';
}
?>